package com.polytech.dao.hibernate;

import java.util.Collection;
import java.util.List;

import org.hibernate.Query;

import com.polytech.beans.Brand;
import com.polytech.beans.Color;
import com.polytech.beans.Model;
import com.polytech.dao.BrandDao;


public class BrandDaoHibernate extends AbstractHibernateDao implements BrandDao {

	@Override
	public void insert(Brand brand) {
		beginTransaction();
			session.save(brand);
		commit();
	}

	@Override
	public Brand select(String key) {
		beginTransaction();
			Brand brand=(Brand)session.get(Brand.class, key);
		commit();
		return brand;
	}

	@Override
	public void remove(Brand brand) {
		beginTransaction();
			session.delete(brand);
		commit();
	}

	@Override
	public Collection<Brand> selectAll() {
		List<Brand> res=null;
		beginTransaction();
		res= (List<Brand>) session.createQuery("from Brand").list();
		commit();
		return res;
	}
	
	
}
